<?php

/**
 * Check if field has been checked
 * 
 * @package Rapide_View
 *
 */
class Rapide_View_Helper_Checked extends Rapide_View_Helper
{
	public function execute($sField, $sUnless = null, $sValue = null)
	{
		$sFieldValue = $this->getView()->value($sField, null, false);

		if(is_null($sFieldValue))
		{
			if(!is_null($sUnless))
			{
				$sFieldValue = $sUnless;
			}
			else
				return;
		}

		if(is_null($sValue))
		{
			return 'checked="checked"';
		}
		elseif($sFieldValue == $sValue)
		{
			return 'checked="checked"';
		}
	}
}

?>